package com.liangzhong.model.mail
{
	import com.common.stdlib.StringUtil;
	import com.liangzhong.model.AppData;
	
	import flash.utils.ByteArray;

	/**
	 *邮件数据解析 
	 * @author lake
	 * 
	 */	
	public class MailServerDataParse
	{
		/**
		 * 读取邮件到来数据
		 * @param data
		 * 
		 */		
		public static function readMailRes(data : ByteArray):Object
		{
			var len :int;
			var mailVo :MailVo = new MailVo();
			mailVo.mailid = data.readShort();
			mailVo.ntype = data.readByte();
			mailVo.bread = data.readByte();
			mailVo.bget = data.readByte();
			mailVo.coin = data.readInt();
			mailVo.fame = data.readInt();
			mailVo.cashpoint = data.readInt();
			mailVo.value1 = data.readInt();
			mailVo.value2 = data.readInt();
			mailVo.value3 = data.readInt();
			mailVo.value4 = data.readInt();
			mailVo.value5 = data.readInt();
			len = data.readShort();
			if(len > 0)
			{
				mailVo.strvalue1 = StringUtil.readStringByByteArray(data,len);
			}
			len = data.readShort();
			if(len > 0)
			{
				mailVo.strvalue2 = StringUtil.readStringByByteArray(data,len);
			}
			len = data.readShort();
			if(len > 0)
			{
				mailVo.strvalue3 = StringUtil.readStringByByteArray(data,len);
			}
			mailVo.time = data.readUnsignedInt();
			AppData.getInstance().mailDataManager.addMail(mailVo);
			return mailVo;
		}
	}
}